package com.cskaoyan;

import com.cskaoyan.dao.UserDao;
import com.cskaoyan.service.OrderService;
import com.cskaoyan.service.UserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author stone
 * @date 2022/03/21 10:06
 */
public class MyTest2 {


    @Test
    public void mytest1() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml");
        UserService userService = applicationContext.getBean(UserService.class);

        OrderService orderService = applicationContext.getBean(OrderService.class);

        UserDao userDao = applicationContext.getBean(UserDao.class);

        //打断点：userService里的userDao、orderService里的userDao、直接从容器中取出的userDao是否是同一个
    }

    @Test
    public void mytest2() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml");
        UserService userService1a = applicationContext.getBean("userService", UserService.class);
        UserService userService1b = applicationContext.getBean("userService", UserService.class);
        UserService userService1c = applicationContext.getBean("userService", UserService.class);

        UserService userService2a = applicationContext.getBean("userService2", UserService.class);
        UserService userService2b = applicationContext.getBean("userService2", UserService.class);
        UserService userService2c = applicationContext.getBean("userService2", UserService.class);
    }
}
